Create an interactive manhattan plot using one command:
#install.packages("manhattanly")
# load the manhattanly library
library(manhattanly)
## See example usage at http://sahirbhatnagar.com/manhattanly/
manhattanly(
subset(
HapMap, CHR %in% 4:7),
snp = "SNP",
gene = "GENE")
manhattanly(subset(HapMap, CHR %in% 4:7), snp = "SNP", gene = "GENE", highlight = significantSNP)
manhattanly(subset(HapMap, CHR %in% 4:7), snp = "SNP", gene = "GENE",
annotation1 = "DISTANCE", annotation2 = "EFFECTSIZE",
highlight = significantSNP)
library(magrittr)
p <- manhattanly(subset(HapMap, CHR %in% 4:7), snp = "SNP", gene = "GENE",
annotation1 = "DISTANCE", annotation2 = "EFFECTSIZE",
highlight = significantSNP)
# get the x and y coordinates from the pre-processed data
plotData <- manhattanr(subset(HapMap, CHR %in% 4:7), snp = "SNP", gene = "GENE")[["data"]]
# annotate the smallest p-value
annotate <- plotData[which.min(plotData$P),]
# x and y coordinates of SNP with smallest p-value
xc <- annotate$pos
yc <- annotate$logp
p %>% plotly::layout(annotations = list(
list(x = xc, y = yc,
text = paste0(annotate$SNP,"<br>","GENE: ",annotate$GENE),
font = list(family = "serif", size = 10))))
Similarly, we can create an interactive Q-Q plot using one command (See help(qqly) for a full list of options):
qqly(subset(HapMap, CHR %in% 4:7), snp = "SNP", gene = "GENE")
volcanoly(subset(HapMap, CHR %in% 4:7), snp = "SNP", gene = "GENE")